<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>分公司管理</title>
<script src="/res/js/common/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/js/common/common.js" type="text/javascript"></script>
<script src="/res/js/structure/struture.js" type="text/javascript"></script> 
<script src="/res/third/layer/layer.js" type="text/javascript"></script>
<link href="/res/css/respective/role/role.css" rel="stylesheet">
<style>
	tr[data-index] td{
	font-weight: bold;} 
</style>
</head>
<body>
[#assign menucode="branchManage"/]
	<div class="warp">
		[#include "/front/common/front_headAzt.html"]
		<div class="backcontent">
			[#include "/front/common/front_leftAzt.html"]
			<div class="back-main">
				<div class="mainContent">
		<div class="mainContentWhite">
			<h1>分公司管理</h1>
			<hr style="margin-bottom: 4px;"/>
			<form id="searchForm"  action="/orgstruct/listBranchCompany" method="post" >
			<div> 
				<div class="search" style="float: left;margin-bottom: 4px;width: 100%;">
				[#if pagination?? && pagination.list?size>5 || bckeyword??]
					<input type="text" class="time" name="so_branchCompany" value="${bckeyword!}" style="margin: 0px;" placeholder="请输入分公司名称" />
					<button type="button" onclick="search();">搜索</button>
				[/#if]
					<button type="button" class="roleButt" onclick="location.href='/orgstruct/fristBranchCompany'" style="float: right;border-radius: 3px;">添加公司</button> 
				</div>
			</div>
			</form>
		<table class="table noBorder" style="text-align: center;">
				<thead>
					<tr style="background-color: #f8f8f8;">
						<th style="width: 20%;">分公司名称</th>
						<th>新增时间</th>
						<th>负责人</th>
						<th>发布项目数</th>
						<th>下单总额</th>
						<th style="width: 25%;">操作</th>
					</tr>
				</thead>
				<tbody>
					<!--默认显示8行-->
					[#if pagination??]
					[#list pagination.list as branchCompany]
					[#assign san=branchCompany.sanCompany /]
					<tr [#if san>0]data-index="${branchCompany_index}"[/#if] attrid="${branchCompany.id!}">
						<td title="查看项目">[#if san>0]<em class="dropDownCom"><a href="/orgstruct/showItems?branchCompanyId=${branchCompany.id!}">${branchCompany.companyName!}</a></em>[#else]<a href="/orgstruct/showItems?branchCompanyId=${branchCompany.id!}">${branchCompany.companyName!}</a>[/#if]</td>
						<td>[#if branchCompany.registertime??]${branchCompany.registertime?string("yyyy-MM-dd")!}[/#if]</td>
						<td>${branchCompany.realName!}</td>
						<td>${branchCompany.publishAmount!}</td>
						<td class="contentBold">￥${branchCompany.orderPrice!}</td>
						<td class="blackLink" style="width: 250px;"><a
							href="/orgstruct/showItems?branchCompanyId=${branchCompany.id!}">查看项目</a>
							<a href="/orgstruct/addBranchCompany?branchCompanyId=${branchCompany.id!}">修改权限</a>
							[#if san==0]<a onclick="delBranchCompany(${branchCompany.id!})" href="javascript:void(0)">删除分公司</a>[#else]<a href="javascript:void(0);" onclick="deltip();" style="width:70px;display:inline-block">删除分公司</a>[/#if]</td>
					</tr>
					[/#list]
					[/#if]
				</tbody> 
				 <tfoot class="goFenYe">
			[@fenye p = pagination form = 'infoForm' /]
			</tfoot>
			</table> 
		</div>
	</div>
			</div>
			<!-- 底部菜单-->
			[#include "/front/common/front_footerAzt.html"]
		</div>
	</div>
	<div id="loadData" style="display:none"></div>
	<script type="text/javascript">
	$(function(){
		$(".dropDownCom").each(function(){
			$(this).click();
		});
	});
	function search(){
		$("#searchForm").submit();
	}
	
	function deltip(){
		layer.msg("不可删除，请先移除下级分公司" , {time:2000} );
	}
	
	function delBranchCompany(branchCompanyId){
		layer.open({
			   title:'提示'
			  ,content: '是否删除分公司？'
			  ,btn: ['确认', '取消']
			  ,yes: function(index, layero){
				  	$.ajax({
						type : "post",
						dataType : "json",
						url : "/orgstruct/delBranchCompany",
						data :{'branchCompanyId' :branchCompanyId},
						success : function(data) {//成功的时候调用
							if(data.success){
								location.reload();
							}else{
								layer.msg(data.msg , {time:2000} );
							}
						}
					});
			  },btn2: function(index, layero){
			  }
			  ,cancel: function(){ 
			    //右上角关闭回调
			  }
			});
	}
    </script>
</body>
</html>